{ Statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=843
  Verdict: Accepted
}
uses
	SysUtils, Math;
 
var
	i, n : longint;
	a : array[0..1010] of longint;
 
begin
	reset(input,'input.txt');
	rewrite(output,'output.txt');
	read(n);
	a[0] := 1;
	a[1] := 1;
	for i := 2 to n do
		if odd(i) then a[i] := a[i shr 1] - a[i shr 1 - 1] else a[i] := a[i shr 1] + a[i shr 1 - 1];
	write(a[n]);
end.